// 引入request
import request from '../util/request.js';
import config from '../util/config.js';
const ToolRequest = {
    BASE_URL : config.tmUrl + "/tm",
    // 请求过程在这里开发，不在.vue文件中开发
    /**
     * 多条件分页查询toolType列表
     * @param tool
     * @param callBack
     */
    loadTool(tool, callBack){
        // 拼接url  /sys/queryByPage?xxx
        let url = this.BASE_URL + "/tool/queryByPage";
        // 调用request进行请求  http://lcation
        request.get(url,tool,callBack);
    },
    /**
     * 新增设备类型的API
     * @param tool
     * @param callBack
     */
    addTool(tool,callBack){
        let url = this.BASE_URL + "/tool/save"
        request.post(url,tool,callBack);
    },
    /**
     * 通过id加载设备类型信息的API
     * @param tool
     * @param callBack
     */
    getById(toolId,callBack){
        let url = this.BASE_URL + "/tool/queryById?toolId=" + toolId;
        request.get(url,null,callBack);
    },

    queryToolTypeNames(callBack){
        let url = this.BASE_URL + "/toolType/queryToolTypeNames";
        request.get(url,null,callBack);
    },

    /**
     * 修改设备类型信息的API
     * @param tool
     * @param callBack
     */
    updateTool(tool,callBack){
        let url = this.BASE_URL + "/tool/update";
        request.post(url,tool,callBack);
    },
    /**
     *  删除设备类型的API
     * @param tool
     * @param callBack
     */
    deleteTool(toolId,callBack){
        request.get(this.BASE_URL + "/tool/delete?toolId=" + toolId,null,callBack);
    },
    /**
     * 批量删除设备类型的API
     * @param toolTypeIds
     * @param callBack
     */
    deleteTools(toolIds,callBack){
        let url = this.BASE_URL + "/tool/deletes?a=1";
        for (let i = 0; i < toolIds.length; i++){
            url += "&toolIds="+toolIds[i];
        }
        request.get(url,null,callBack);
    }
}
// 导出我们申明的dictrequest对象
export default ToolRequest;